<!--
 * @Description: 
 * @Author: mxy
 * @Date: 2022-11-28 20:14:51
 * @LastEditors: mxy
 * @LastEditTime: 2022-11-28 20:14:51
-->
<!--
 * @Description: 
 * @Author: mxy
 * @Date: 2022-11-28 18:35:56
 * @LastEditors: mxy
 * @LastEditTime: 2022-11-28 20:14:45
-->
<template>
  <div>
    <h2>计算属性完整写法</h2>
    <input type="text" v-model="xing" />
    <input type="text" v-model="ming" />
    <input type="text" v-model="fullname" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      xing: "",
      ming: "",
    };
  },
  computed: {
    // 完整写法就是外边是个对象，里边两个函数
    fullname: {
      //get就是当获取计算属性时，就会调用get
      get() {
        return this.xing + " " + this.ming;
      },
      //当计算属性被修改时，调用set，参数就是修改后的值
      set(val) {
        this.xing = val.split(" ")[0];
        this.ming = val.split(" ")[1];
      },
    },
  },
};
</script>

<style>
</style>